\defmodule {DiscreteDistributionIntMulti}

Classes implementing multi-dimensional discrete distributions over the integers
should inherit from this class.
It specifies the signature of methods for computing the mass function
(or probability) $p(x_1, x_2, \ldots, x_d) = 
 P[X_1 = x_1, X_2 = x_2, \ldots, X_d = x_d]$ and the cumulative probabilities 
for a random vector $X$ with a discrete distribution over the integers.

\bigskip\hrule

\begin{code}
\begin{hide}
/*
 * Class:        DiscreteDistributionIntMulti
 * Description:  mother class for discrete distributions over the integers
 * Environment:  Java
 * Software:     SSJ 
 * Copyright (C) 2001  Pierre L'Ecuyer and Universite de Montreal
 * Organization: DIRO, Universite de Montreal
 * @author       
 * @since

 * SSJ is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License (GPL) as published by the
 * Free Software Foundation, either version 3 of the License, or
 * any later version.

 * SSJ is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * A copy of the GNU General Public License is available at
   <a href="http://www.gnu.org/licenses">GPL licence site</a>.
 */
\end{hide}
package umontreal.iro.lecuyer.probdistmulti;


public abstract class DiscreteDistributionIntMulti\begin{hide} {
   protected int dimension;
  \end{hide}

   public abstract double prob (int[] x);
\end{code}
\begin{tabb}  Returns the probability mass function $p(x_1, x_2, \ldots, x_d)$,
   which should be a real number in $[0,1]$.
 % The notation used is $\texttt{x[i-1]} = x_i$.
\end{tabb}
\begin{htmlonly}
   \param{x}{value at which the mass function must be evaluated}
   \return{the mass function evaluated at \texttt{x}}
\end{htmlonly}
\begin{code}

   public double cdf (int x[])\begin{hide} {
      int is[] = new int[x.length];
      for (int i = 0; i < is.length; i++)
         is[i] = 0;

      boolean end = false;
      double sum = 0.0;
      int j;
      while (!end) {
         sum += prob (is);
         is[0]++;

         if (is[0] > x[0]) {
            is[0] = 0;
            j = 1;
            while (j < x.length && is[j] == x[j])
               is[j++] = 0;

            if (j == x.length)
               end = true;
            else
               is[j]++;
         }
      }

      return sum;
   }\end{hide}
\end{code}
\begin{tabb}
   Computes the cumulative probability function $F$ of the distribution evaluated
   at \texttt{x}, assuming the lowest values start at 0, i.e. computes
$$
  F (x_1, x_2, \ldots, x_d) = 
  \sum_{s_1=0}^{x_1} \sum_{s_2=0}^{x_2} \cdots
   \sum_{s_d=0}^{x_d} p(s_1, s_2, \ldots, s_d).
$$
   Uses the naive implementation, is very inefficient and may underflows.
\end{tabb}
\begin{code}

   public int getDimension()\begin{hide} {
      return dimension;
   }\end{hide}
\end{code}
\begin{tabb}
   Returns the dimension $d$ of the distribution.
\end{tabb}
\begin{code}

   public abstract double[] getMean();
\end{code}
\begin{tabb}
   Returns the mean vector of the distribution, defined as $\mu_{i} = E[X_i]$.
\end{tabb}
\begin{code}

   public abstract double[][] getCovariance();
\end{code}
\begin{tabb}
   Returns the variance-covariance matrix of the distribution, defined as\\
   $\sigma_{ij} = E[(X_i - \mu_i)(X_j - \mu_j)]$.
\end{tabb}
\begin{code}

   public abstract double[][] getCorrelation();
\end{code}
\begin{tabb}
   Returns the correlation matrix of the distribution, defined as
      $\rho_{ij} = \sigma_{ij}/\sqrt{\sigma_{ii}\sigma_{jj}}$.
\end{tabb}
\begin{code}\begin{hide}
}\end{hide}
\end{code}
